#include <cstdio>
#include <vector>
#include <cstring>
#include <queue>
#define MAXN 510
#define INF 0x3f3f3f3f
using namespace std;
int F, N, M, W;
int dp[MAXN];
bool in[MAXN];
int time[MAXN];

struct edge {
    int to, cost;
    edge(int _v, int _c): to(_v), cost(_c) {}
};

vector<edge> e[MAXN];

void solve();
int main() {
    int f, t, c;
    scanf("%d", &F);
    while (F--) {
        scanf("%d %d %d", &N, &M, &W);
        for (int i = 1; i <= N; i++) e[i].clear();
        for (int i = 0; i < M; i++) {
            scanf("%d %d %d", &f, &t, &c);
            e[f].push_back(edge(t, c));
            e[t].push_back(edge(f, c));
        }

        for (int i = 0; i < W; i++) {
            scanf("%d %d %d", &f, &t, &c);
            e[f].push_back(edge(t, -c));
        }
        solve();
    }
}

void solve() {
    memset(in, 0, sizeof in);
    memset(time, 0, sizeof time);
    memset(dp, INF, sizeof dp);
    queue<int> q;
    dp[1] = 0; q.push(1); in[1] = true; time[1] = 1;
    while (!q.empty()) {
        int v = q.front(); q.pop(); in[v] = false;
        vector<edge> edges = e[v];
        for (edge es: edges) {
            if (dp[es.to] > dp[v] + es.cost) {
                dp[es.to] = dp[v] + es.cost;
                if (!in[es.to]) {
                    in[es.to] = true;
                    time[es.to]++;
                    q.push(es.to);
                }
            }
            if (time[es.to] > N) {
                printf("YES\n");
                return;
            }
        }
    }

    printf("NO\n");
    
}